#include "test_list.h"


#ifdef TEST_VARIANT_SERIALIZATION

#include "disable_warning.h"

//------------------------------------------------------------

#include "tools/serialization.h"

//------------------------------------------------------------


#include "tools/variant.h"

#define TEST_VARIANT_SERIALIZATION_000
#define TEST_VARIANT_SERIALIZATION_001
#define TEST_VARIANT_SERIALIZATION_002
#define TEST_VARIANT_SERIALIZATION_003
#define TEST_VARIANT_SERIALIZATION_004
#define TEST_VARIANT_SERIALIZATION_005
#define TEST_VARIANT_SERIALIZATION_006
#define TEST_VARIANT_SERIALIZATION_007
#define TEST_VARIANT_SERIALIZATION_008
#define TEST_VARIANT_SERIALIZATION_009
#define TEST_VARIANT_SERIALIZATION_010
#define TEST_VARIANT_SERIALIZATION_011
#define TEST_VARIANT_SERIALIZATION_012
#define TEST_VARIANT_SERIALIZATION_013
#define TEST_VARIANT_SERIALIZATION_014
#define TEST_VARIANT_SERIALIZATION_015
#define TEST_VARIANT_SERIALIZATION_016
#define TEST_VARIANT_SERIALIZATION_017
#define TEST_VARIANT_SERIALIZATION_018
#define TEST_VARIANT_SERIALIZATION_019
#define TEST_VARIANT_SERIALIZATION_020
#define TEST_VARIANT_SERIALIZATION_021
#define TEST_VARIANT_SERIALIZATION_022
#define TEST_VARIANT_SERIALIZATION_023
#define TEST_VARIANT_SERIALIZATION_024
#define TEST_VARIANT_SERIALIZATION_025
#define TEST_VARIANT_SERIALIZATION_026
#define TEST_VARIANT_SERIALIZATION_027
#define TEST_VARIANT_SERIALIZATION_028
#define TEST_VARIANT_SERIALIZATION_029
#define TEST_VARIANT_SERIALIZATION_030
#define TEST_VARIANT_SERIALIZATION_031
#define TEST_VARIANT_SERIALIZATION_032

//using namespace variant_detail;

//------------------------------------------------------------------------------------------------------//
namespace{

    typedef variant_detail::V::I8         I8;
    typedef variant_detail::V::I16        I16;
    typedef variant_detail::V::I32        I32;
    typedef variant_detail::V::I64        I64;
    typedef variant_detail::V::U8         U8;
    typedef variant_detail::V::U16        U16;
    typedef variant_detail::V::U32        U32;
    typedef variant_detail::V::U64        U64;
    typedef variant_detail::V::F32        F32;
    typedef variant_detail::V::F64        F64;
    typedef variant_detail::V::Byte       Byte;
    typedef variant_detail::V::WChar      WChar;
    typedef variant_detail::V::Str        Str;
    typedef variant_detail::V::WStr       WStr;
    typedef variant_detail::V::Vec        Vec;
    typedef variant_detail::V::Map        Map;
    typedef variant_detail::V::Blob       Blob;
    typedef variant_detail::V::List       List;

    typedef variant_detail::V::Record     Record;
    typedef variant_detail::V::Records    Records;

    Variant GetSeializedBinary(const Variant& v)
    {
        Blob serialized;
        SerializeBinary(v, serialized);
        Variant _v;
        DeserializeBinary(serialized, _v);
        return _v;
    }

    Variant GetSeializedText(const Variant& v)
    {
        Str serialized;
        SerializeText(v, serialized);
        Variant _v;
        DeserializeText(serialized, _v);
        return _v;
    }

    Variant GetSeializedXml(const Variant& v)
    {
        Str serialized;
        SerializeXml(v, serialized);
        Variant _v;
        DeserializeXml(serialized, _v);
        return _v;
    }



}//namespace



//------------------------------------------------------------------------------------------------------//

#ifdef TEST_VARIANT_SERIALIZATION_000
TEST(Variant, serialize_000)
{
    Variant v1;
    Variant v2 = GetSeializedBinary(v1);
    EXPECT_EQ(v1.GetType(), v2.GetType() ); 
    EXPECT_EQ(true, v2.Empty() ); 
}
#endif // TEST_VARIANT_SERIALIZATION_000

#ifdef TEST_VARIANT_SERIALIZATION_001
TEST(Variant, serialize_001)
{
    Variant v1 = I32(10);
    Variant v2 = GetSeializedBinary(v1);
    v1==v2;
    EXPECT_EQ(true, v1==v2 ); 
}
#endif // TEST_VARIANT_SERIALIZATION_001

#ifdef TEST_VARIANT_SERIALIZATION_002
TEST(Variant, serialize_002)
{
    { Variant v = I8(-10);           EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = I16(-10);          EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = I32(-10);          EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = I64(-10);          EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = U8(10);            EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = U16(10);           EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = U32(10);           EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = U64(10);           EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = F32(-3.35f);       EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = F64(0.3434E22);    EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = Byte(0x34);        EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = true;              EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = "Hello lolo";      EXPECT_EQ(v, GetSeializedBinary(v)); }
    { Variant v = L"Hello lolo";     EXPECT_EQ(v, GetSeializedBinary(v)); }
}
#endif // TEST_VARIANT_SERIALIZATION_002

#ifdef TEST_VARIANT_SERIALIZATION_003
TEST(Variant, serialize_003)
{
    Vec vec(5);
    vec[0] = "Hi";
    vec[1] = L"Yo";
    vec[2] = 10;
    vec[3] = 0.454;
    vec[4] = 'g';
    Variant v =  vec;                      
    EXPECT_EQ(v, GetSeializedBinary(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_003

#ifdef TEST_VARIANT_SERIALIZATION_004
TEST(Variant, serialize_004)
{
    Map map;
    map["First"] = "Hi";
    map["Second"] = L"Yo";
    map["Third"] = 10;
    map["Fourth"] = 0.454;
    map["Fifth"] = 'g';
    Variant v = map;                      
    EXPECT_EQ(v, GetSeializedBinary(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_004

#ifdef TEST_VARIANT_SERIALIZATION_005
TEST(Variant, serialize_005)
{
    Variant v = Blob(10, 0x34);         
    EXPECT_EQ(v, GetSeializedBinary(v));
}
#endif // TEST_VARIANT_SERIALIZATION_005

#ifdef TEST_VARIANT_SERIALIZATION_006
TEST(Variant, serialize_006)
{
    Record rec("Val", 34343u);      
    Variant v = rec;
    EXPECT_EQ(v, GetSeializedBinary(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_006

#ifdef TEST_VARIANT_SERIALIZATION_007
TEST(Variant, serialize_007)
{
    Variant v = Records(10, Record("Val", 32323.343));
    EXPECT_EQ(v, GetSeializedBinary(v));
}
#endif // TEST_VARIANT_SERIALIZATION_007

#ifdef TEST_VARIANT_SERIALIZATION_008
TEST(Variant, serialize_008)
{
    { Variant v;                      EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = I8  (-10);          EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = I16 (-10);          EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = I32 (-10);          EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = I64 (-10);          EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = U8  (10);           EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = U16 (10);           EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = U32 (10);           EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = U64 (10);           EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = F32 (-3.35);        EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = F64 (0.3434E22);    EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = Byte(0x34);         EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = true;               EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = "Hello lolo";       EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = L"Hello lolo";      EXPECT_EQ(v, GetSeializedText(v)); }
}
#endif // TEST_VARIANT_SERIALIZATION_008

#ifdef TEST_VARIANT_SERIALIZATION_009
TEST(Variant, serialize_009)
{
    Vec vec(5);
    vec[0] = "Hi";
    vec[1] = L"Yo";
    vec[2] = 10;
    vec[3] = 0.454;
    vec[4] = 'g';
    Variant v =  vec;                      
    EXPECT_EQ(v, GetSeializedText(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_009

#ifdef TEST_VARIANT_SERIALIZATION_010
TEST(Variant, serialize_010)
{
    Map map;
    map["First"] = "Hi";
    map["Second"] = L"Yo";
    map["Third"] = 10;
    map["Fourth"] = 0.454;
    map["Fifth"] = 'g';
    Variant v = map;                      
    EXPECT_EQ(v, GetSeializedBinary(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_010

#ifdef TEST_VARIANT_SERIALIZATION_011
TEST(Variant, serialize_011)
{
    Variant v = Blob(10, 0x34);                 
    EXPECT_EQ(v, GetSeializedText(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_011

#ifdef TEST_VARIANT_SERIALIZATION_012
TEST(Variant, serialize_012)
{
    { Variant v = Record("Val", 34343u);                 EXPECT_EQ(v, GetSeializedText(v)); }
    { Variant v = Records(10, Record("Val", 32323.343)); EXPECT_EQ(v, GetSeializedText(v)); }
}
#endif // TEST_VARIANT_SERIALIZATION_012

#ifdef TEST_VARIANT_SERIALIZATION_013
TEST(Variant, serialize_013)
{
    { Variant v;                      EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = I8  (-10);          EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = I16 (-10);          EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = I32 (-10);          EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = I64 (-10);          EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = U8  (10);           EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = U16 (10);           EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = U32 (10);           EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = U64 (10);           EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = F32 (-3.35);        EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = F64 (0.3434E22);    EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = Byte(0x34);         EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = true;               EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = "Hello lolo";       EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = L"Hello lolo";      EXPECT_EQ(v, GetSeializedXml(v)); }
}
#endif // TEST_VARIANT_SERIALIZATION_013

#ifdef TEST_VARIANT_SERIALIZATION_014
TEST(Variant, serialize_014)
{
    Vec vec(5);
    vec[0] = "Hi";
    vec[1] = L"Yo";
    vec[2] = 10;
    vec[3] = 0.454;
    vec[4] = 'g';
    Variant v =  vec;                      
    EXPECT_EQ(v, GetSeializedXml(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_014

#ifdef TEST_VARIANT_SERIALIZATION_015
TEST(Variant, serialize_015)
{
    Map map;
    map["First"] = "Hi";
    map["Second"] = L"Yo";
    map["Third"] = 10;
    map["Fourth"] = 0.454;
    map["Fifth"] = 'g';
    Variant v = map;                      
    EXPECT_EQ(v, GetSeializedXml(v)); 
}
#endif // TEST_VARIANT_SERIALIZATION_015

#ifdef TEST_VARIANT_SERIALIZATION_016
TEST(Variant, serialize_016)
{
    Variant v = Blob(10, 0x34); 
    EXPECT_EQ(v, GetSeializedXml(v));
}
#endif // TEST_VARIANT_SERIALIZATION_016

#ifdef TEST_VARIANT_SERIALIZATION_017
TEST(Variant, serialize_017)
{
    { Variant v = Record("Val", 34343u);                 EXPECT_EQ(v, GetSeializedXml(v)); }
    { Variant v = Records(10, Record("Val", 32323.343)); EXPECT_EQ(v, GetSeializedXml(v)); }
}
#endif // TEST_VARIANT_SERIALIZATION_017

#ifdef TEST_VARIANT_SERIALIZATION_018
TEST(Variant, serialize_018)
{
    { Variant v;                    Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = I8  (-10);        Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = I16 (-10);        Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = I32 (-10);        Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = I64 (-10);        Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = U8  (10);         Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = U16 (10);         Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = U32 (10);         Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = U64 (10);         Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = F32 (-3.35);      Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = F64 (0.3434E22);  Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = Byte(0x34);       Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = true;             Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = "Hello lolo";     Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = L"Hello lolo";    Variant _v = v; EXPECT_EQ(v, _v); }

    { 
        Vec vec(5);
        vec[0] = "Hi";
        vec[1] = L"Yo";
        vec[2] = 10;
        vec[3] = 0.454;
        vec[4] = 'g';
        Variant v =  vec;                    
        Variant _v = v;
        EXPECT_EQ(v, _v); 
    }
    { 
        Map map;
        map["First"] = "Hi";
        map["Second"] = L"Yo";
        map["Third"] = 10;
        map["Fourth"] = 0.454;
        map["Fifth"] = 'g';
        Variant v = map;                                         
        Variant _v = v; EXPECT_EQ(v, _v);
    }

    { Variant v = Blob(10, 0x34);                        Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = Record("Val", 34343u);                 Variant _v = v; EXPECT_EQ(v, _v); }
    { Variant v = Records(10, Record("Val", 32323.343)); Variant _v = v; EXPECT_EQ(v, _v); }

}
#endif // TEST_VARIANT_SERIALIZATION_018

#ifdef TEST_VARIANT_SERIALIZATION_019
#endif // TEST_VARIANT_SERIALIZATION_019

#ifdef TEST_VARIANT_SERIALIZATION_020
#endif // TEST_VARIANT_SERIALIZATION_020

#ifdef TEST_VARIANT_SERIALIZATION_021
#endif // TEST_VARIANT_SERIALIZATION_021

#ifdef TEST_VARIANT_SERIALIZATION_022
#endif // TEST_VARIANT_SERIALIZATION_022

#ifdef TEST_VARIANT_SERIALIZATION_023
#endif // TEST_VARIANT_SERIALIZATION_023

#ifdef TEST_VARIANT_SERIALIZATION_024
#endif // TEST_VARIANT_SERIALIZATION_024

#ifdef TEST_VARIANT_SERIALIZATION_025
#endif // TEST_VARIANT_SERIALIZATION_025

#ifdef TEST_VARIANT_SERIALIZATION_026
#endif // TEST_VARIANT_SERIALIZATION_026

#ifdef TEST_VARIANT_SERIALIZATION_027
#endif // TEST_VARIANT_SERIALIZATION_027

#ifdef TEST_VARIANT_SERIALIZATION_028
#endif // TEST_VARIANT_SERIALIZATION_029

#ifdef TEST_VARIANT_SERIALIZATION_030
#endif // TEST_VARIANT_SERIALIZATION_030

#ifdef TEST_VARIANT_SERIALIZATION_031
#endif // TEST_VARIANT_SERIALIZATION_031

#ifdef TEST_VARIANT_SERIALIZATION_032
#endif // TEST_VARIANT_SERIALIZATION_032

#include "default_warning.h"

#endif



